#!/usr/bin/env groovy
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def serverDir,projectName,version,image,current_date

def getDockerImageID(dockerImageID){
    def new_dockerImageID = sh (returnStdout: true, script: 'echo ${dockerImageID} | awk -F: \'{print $2}\'').trim()
    return new_dockerImageID                            
}

def checkDockerImage(dockerImageID){
    def new_DockerImage = sh (returnStdout: true, script: 'echo ${dockerImageID} |  awk -F: \'{print $1}\' | awk -F/ \'{print $NF}\'').trim()
    return new_DockerImage
}

def updateAlarmCopy() {
   sh '''
   JENKINS_NODE_COOKIE=dontKillMe nohup /data/script/podStatus.sh > /data/script/podStatus.out 2>&1 &
   '''
}

pipeline {

    agent {
       label "jenkinsNode-21"
    }
    environment {
        def BUILD_TIME = sh(script: "echo `date '+%Y-%m-%d %H:%M'`", returnStdout: true).trim()
        imagePullPolicy = "IfNotPresent" //IfNotPresent
        k8sOpsDir = "/data/jenkins/cfhy-k8s"
        PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
    }
    parameters {
        choice(name: 'k8sNamespace', choices: ['prod'], description: '请选择k8s命名空间')
        choice(choices: ['','account-server','accounting-center-server','admin-center-server','app-gateway','auth-server','base-center-server','basic-carrier-server','bi-crm-server',
'bi-search-server','contract-signing-center-server','credit-center-server','crm-center-server','cw-server','es-center-server','finance-risk-server','file-server','finance-server','gas-server','gateway-server',
'hardware-support-center-server','hz-server','insurance-server','interface-server','jjr-server','lbs-server','message-center-server','mongo-server','ncrm-gateway',
'ncrm-server','order-center-server','order-pro-server','pay-center-server','pub-server','quota-server','process-engine-server','risk-server','risk-feature-server','risk-engine-server','sj-server','statistics-center-server',
'support-order-server','sys-server','tech-server','third-server','user-center-server'], description: '选择要部署的微服务', name: 'app_name')
        string(name: 'dockerImageID', defaultValue: '', description: 'docker镜像 example:  swr.cn-north-4.myhuaweicloud.com/cfhy-dev/xxx-xxx-xxx:776-054591a')
        choice(choices: ['N','Y'], description: '是否操作告警副本', name: 'monitoringUpdate')
    }
    stages {
        stage('Update alarm copy') {
            steps {
                script {
                    def isMonitoringUpdate = params.monitoringUpdate
        
                    if (isMonitoringUpdate == 'Y') {
                        echo "开始检测 POD STATUS"
                        updateAlarmCopy()
                    } else {
                        echo "未操作告警副本"
                    }
                }
            }
        }
        stage('deploy k8s') {
            steps{
                script { 
                    //获取docker tag
                    version=getDockerImageID(dockerImageID)
                    checkImage=checkDockerImage(dockerImageID)
                    if ( version == '') {
                        echo "docker镜像为空或输入错误，请输入对应服务正确的docker镜像,并重新构建."
                        sh "exit 1"
                    }else if ( checkImage != app_name) {
                        echo "docker镜像输入错误或服务选择错误，请检查后重新构建"
                        sh "exit 1"
                    }else if ( app_name == "account-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=2000m \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "accounting-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=3 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=5632M \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "admin-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=3 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=180 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=180 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.system_args=-XX:HeapDumpPath=/usr/software/service/admin.hprof \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=500m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "app-gateway") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                                --set replicaCount=4 \
                                --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                                --set secret.projectEnvSecret.name=project-secret \
                                --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                                --set image.tag=$version \
                                --set pod.probe.probes.livenessProbe.initialDelaySeconds=130 \
                                --set pod.probe.probes.readinessProbe.initialDelaySeconds=130 \
                                --set resources.requests.memory=2048Mi \
                                --set resources.limits.memory=8192Mi \
                                --set resources.requests.cpu=300m \
                                --set resources.limits.cpu=4000m \
                                --set apm.enabled=true \
                                --set apm.service=oneapm \
                                --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "auth-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set env.system_args=-XX:HeapDumpPath=/usr/software/service/auth.hprof \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "base-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version

                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                              --set replicaCount=2 \
                              --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                              --set secret.projectEnvSecret.name=project-secret \
                              --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                              --set image.tag=$version \
                              --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                              --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                              --set apm.enabled=true \
                              --set apm.service=oneapm \
                              --set env.jvm_xms=2048M \
                              --set env.jvm_xmx=6144M \
                              --set resources.requests.memory=4096Mi \
                              --set resources.limits.memory=8192Mi \
                              --set resources.requests.cpu=300m \
                              --set resources.limits.cpu=4000m \
                              --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "basic-carrier-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "bi-crm-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i  -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "bi-search-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i  -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "contract-signing-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=3 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-dev/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=4096Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "credit-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "crm-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                                --set replicaCount=2 \
                                --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                                --set secret.projectEnvSecret.name=project-secret \
                                --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                                --set image.tag=$version \
                                --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                                --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                                --set resources.requests.memory=2048Mi \
                                --set resources.limits.memory=8192Mi \
                                --set resources.requests.cpu=300m \
                                --set resources.limits.cpu=4000m \
                                --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "cw-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "es-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "file-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "finance-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "finance-risk-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set deployment.terminationGracePeriodSeconds=60 \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "gas-server" ) {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --set apm.oneapm.image.tag=jdk17-alpha-1.0 \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "gateway-server" ) {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                              --set replicaCount=2 \
                              --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                              --set secret.projectEnvSecret.name=project-secret \
                              --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                              --set image.tag=$version \
                              --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                              --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                              --set resources.requests.memory=2048Mi \
                              --set resources.limits.memory=8192Mi \
                              --set resources.requests.cpu=300m \
                              --set resources.limits.cpu=4000m \
                              --set apm.enabled=true \
                              --set apm.service=oneapm \
                              --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "hardware-support-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=4 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=12288Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=8192M \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "hz-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "insurance-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "interface-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set image.tag=$version \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "jjr-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "lbs-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "marketing-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "message-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set image.tag=$version \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "mongo-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=3 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "ncrm-gateway") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                                --set replicaCount=2 \
                                --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                                --set secret.projectEnvSecret.name=project-secret \
                                --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                                --set image.tag=$version \
                                --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                                --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                                --set resources.requests.memory=2048Mi \
                                --set resources.limits.memory=8192Mi \
                                --set resources.requests.cpu=300m \
                                --set resources.limits.cpu=4000m \
                                --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "ncrm-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "order-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=6 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=180 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=180 \
                            --set env.system_args=-XX:HeapDumpPath=/usr/software/service/order.hprof \
                            --set resources.requests.memory=8192Mi \
                            --set resources.limits.memory=12288Mi \
                            --set resources.requests.cpu=500m \
                            --set resources.limits.cpu=8000m \
                            --set deployment.RollingUpdate.maxSurge="100%" \
                            --set deployment.RollingUpdate.maxUnavailable="25%" \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=8192M \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "order-pro-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "pay-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=4 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set image.tag=$version \
                            --set resources.requests.memory=6144Mi \
                            --set resources.limits.memory=12288Mi \
                            --set resources.requests.cpu=500m \
                            --set resources.limits.cpu=4000m \
                            --set env.jvm_xms=5120M \
                            --set env.jvm_xmx=9216M \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --set deployment.terminationGracePeriodSeconds=7200 \
                            --set deployment.RollingUpdate.maxSurge="100%" \
                            --set deployment.RollingUpdate.maxUnavailable="25%" \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "pub-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "quota-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "process-engine-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "risk-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=4 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set env.system_args=-XX:HeapDumpPath=/usr/software/service/risk.hprof \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "risk-feature-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "risk-engine-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "sj-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "statistics-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set resources.requests.memory=8192Mi \
                            --set resources.limits.memory=16384Mi \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=8192M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "support-order-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "sys-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=4096Mi \
                            --set resources.limits.memory=8192Mi \
                            --set env.jvm_xms=2048M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    } else if ( app_name == "tech-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace}  $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=120 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=120 \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "third-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=2 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=100 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=100 \
                            --set image.tag=$version \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=2048M \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce 
                        """
                    } else if ( app_name == "user-center-server") {
                        //获取项目名称
                        projectName = app_name
                        sh """
                            echo $projectName
                            echo $version
                            helm upgrade -i -n${params.k8sNamespace} $projectName ${k8sOpsDir}/helm/environment/prod/gaia-chart \
                            --set replicaCount=4 \
                            --set secret.imageRegistrySecret.name=huaweicloud-registry-secret \
                            --set secret.projectEnvSecret.name=project-secret \
                            --set image.repository=swr.cn-north-4.myhuaweicloud.com/cfhy-prod/$projectName \
                            --set image.tag=$version \
                            --set pod.probe.probes.livenessProbe.initialDelaySeconds=150 \
                            --set pod.probe.probes.readinessProbe.initialDelaySeconds=150 \
                            --set env.jvm_xms=1024M \
                            --set env.jvm_xmx=6144M \
                            --set resources.requests.memory=2048Mi \
                            --set resources.limits.memory=8192Mi \
                            --set resources.requests.cpu=300m \
                            --set resources.limits.cpu=4000m \
                            --set apm.enabled=true \
                            --set apm.service=oneapm \
                            --kube-context=cfhy-prod-cce
                        """
                    }
                }
            }
        } 
    }
    post {
        always {
			script {
                if (currentBuild.result == "SUCCESS") {
                    dingtalk (
                    robot: '6065270a-fbc0-4d14-9ce8-8cf765595b4e',
                    type: 'MARKDOWN',
                    atAll: false,
                    title: "${app_name}上线成功!",
                    text: ["- ${app_name}上线成功! \n- 持续时间:${currentBuild.durationString} \n- 构建时间:  ${BUILD_TIME}"],
                    messageUrl: "${BUILD_URL}/console",
                    picUrl: 'http://kmzsccfile.kmzscc.com/upload/2020/success.jpg',
                    singleTitle: '',
                    btns: [],
                    hideAvatar: false
                    )
                } else {
                    dingtalk (
                    robot: '6065270a-fbc0-4d14-9ce8-8cf765595b4e',
                    type: 'LINK',
                    atAll: false,
                    title: "${app_name}上线失败!",
                    messageUrl: "${BUILD_URL}/console",
                    picUrl: 'http://kmzsccfile.kmzscc.com/upload/2020/error.jpg',
                    singleTitle: '',
                    btns: [],
                    hideAvatar: false
                    )  
                }
            }
        }
    }
}